package cn.zh.npro.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import cn.zh.npro.Item.CaItem;
import cn.zh.npro.R;

/**
 * Created by WYN on 2018/3/19 0019.
 */

public class ReAdapter extends BaseAdapter{
    Context context;
    ArrayList<CaItem> arrayList;
    LayoutInflater inflater;

    public ReAdapter(Context context, ArrayList<CaItem> arrayList) {
        this.context = context;
        this.arrayList = arrayList;
        inflater=LayoutInflater.from(context);
        }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder=null;
        if (null==view){
            holder=new Holder();
            view=inflater.inflate(R.layout.re_layout,null,false);
            holder.rname=view.findViewById(R.id.rname);
            holder.rph=view.findViewById(R.id.rph);
            holder.radr=view.findViewById(R.id.radr);
            view.setTag(holder);
         }else {
            holder= (Holder) view.getTag();
          }
          holder.rname.setText(arrayList.get(i).getFullname());
          holder.rph.setText(arrayList.get(i).getMobile());
          holder.radr.setText(arrayList.get(i).getAddress());

        return view;
      }




     public class Holder{
        TextView rname,rph,radr;
        }
     }
